package com.qzimp.fujiancuo.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.qzimp.fujiancuo.entity.AdminLog;
import com.qzimp.fujiancuo.entity.dto.AdminLogDTO;
import com.qzimp.fujiancuo.mapper.AdminLogMapper;
import com.qzimp.fujiancuo.service.AdminLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  服务层实现。
 *
 * @author 吴宗波
 * @since 2024-11-21
 */
@Service
@CacheConfig(cacheNames = "adminLog")
public class AdminLogServiceImpl extends ServiceImpl<AdminLogMapper, AdminLog> implements AdminLogService {

    @Autowired
    private AdminLogMapper adminLogMapper;

    @Override
    public List<AdminLog> queryAdminLogs(Integer adminId) {

        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("admin_id",adminId);
        return adminLogMapper.selectListByQuery(queryWrapper);
    }
    // 查询管理员操作日志
    @Override
    public List<AdminLogDTO> getAdminLogsByAdminId(Integer adminId) {
        // 这里执行数据库查询，返回DTO列表
        return adminLogMapper.selectAdminLogsWithAdminInfoByAdminId(adminId);
    }
}
